package j03zuoye;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Z2mapTest {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        map.put("Tom","CoreJava");
        map.put("Jone","Oracle");
        map.put("Susan","Oracle");
        map.put("Jerry","JDBC");
        map.put("Jim","Unix");
        map.put("Kevin","JSP");
        map.put("Lucy","JSP");
        //增加
        map.put("Allen","JDBC");

        map.replace("Lucy","CoreJava");
        System.out.println(map);
        System.out.println("===");
//        Set<String> keyArr = map.keySet();
//        for (String key : keyArr) {
//            System.out.println(key+"-"+map.get(key));
//        }
        Set<Map.Entry<String,String>> entrySet = map.entrySet();
        Iterator<Map.Entry<String,String>> it = entrySet.iterator();
        while (it.hasNext()){
            Map.Entry<String,String> entry = it.next();
            if(entry.getValue().equals("JSP")){
                System.out.println(entry.getKey()+"-"+entry.getValue());
            }
        }

    }
}
